<?php 

require_once ("log.php");
error_reporting(E_ERROR);
require_once ("cloud_api.php");

class cloud_login {
	// 进入登陆界面 
	function login_main() { 
		global $v_file;
		require($v_file);
	}
	// 登陆操作
	function login_oper() {
		global $mysql_conn;
		$bot_name = $_POST['bot_name'];
		$bot_password = $_POST['bot_password'];
		$row = simQuery("SELECT * from robot WHERE name = '{$bot_name}'");
		if (!empty($row)) {
			if ($bot_password == $row['password']) {
				if ($row['status'] != '0') {
					$bot_id 		= $row['id'];				// 机器人id
					$bot_work_data	= $row['service_period'];
					setcookie("bot_id", $bot_id, time()+3600);
					setcookie("bot_work_data", $bot_work_data, time()+3600);
					echo "4"; // 密码正确
				} else {
					echo "3"; // 机器人过期
				}
			} else {
				echo "2"; // 密码不正确
			}
		} else {
			echo "1"; // 用户不存在
		}
	}

	// 离开
	function login_exit() {
		setcookie("bot_id", "", time()-3600);
		setcookie("bot_work_data", "", time()-3600);
		echo "1";
	}
} 
/* End of file democontroller.php */ 